Skip to content

Conversation

@guohao-rosicky
Copy link
Contributor

@guohao-rosicky guohao-rosicky commented Jun 25, 2023

What changes were proposed in this pull request?

Added support for stream on S3Gateway write path

This section does not include multipart uploads.

ZERO copy is not used, and subsequent optimization is performed.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-5869

How was this patch tested?

Existing test
ci: https://github.com/guohao-rosicky/ozone/actions/runs/5364940200

@guohao-rosicky
Copy link
Contributor Author

hi @szetszwo PTAL thanks.

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guohao-rosicky , thanks a lot for working on this! Please see the comment inlined. Could you also add a test?

Comment on lines 99 to 120
byte[] buffer = new byte[bufferSize];
ByteBuffer writeByteBuffer;
long total = 0;
do {
int realBufferSize = (int) (length - total);
if (realBufferSize > 0 && realBufferSize < bufferSize) {
buffer = new byte[realBufferSize];
}
int nn = body.read(buffer);
if (nn == -1) {
break;
} else if (nn != bufferSize) {
byte[] subBuffer = new byte[nn];
System.arraycopy(buffer, 0, subBuffer, 0, nn);
writeByteBuffer = ByteBuffer.wrap(subBuffer, 0, nn);
} else {
writeByteBuffer = ByteBuffer.wrap(buffer, 0, nn);
}
streamOutput.write(writeByteBuffer, 0, nn);
total += nn;
} while (total != length);
return total;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method can be simplified to

    final byte[] buffer = new byte[bufferSize];
    long n = 0;
    while (n < length) {
      final int toRead = Math.toIntExact(Math.min(bufferSize, length - n));
      final int readLength = body.read(buffer, 0, toRead);
      if (readLength == -1) {
        break;
      }
      streamOutput.write(ByteBuffer.wrap(buffer, 0, readLength));
      n += readLength;
    }
    return n;

body = new SignedChunksInputStream(body);
}
long putLength = 0;
if (datastreamEnabled && !enableEC) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we use Streaming only if it has more than one chunk?

      if (datastreamEnabled && !enableEC && length > chunkSize) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @szetszwo review this.
I think it is ok, whether this is better to have a display configuration, and then this configuration can be decided by the user, if you think it is possible, I can add this configuration

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guohao-rosicky , yes, it is a good idea. How about we reuse the OZONE_FS_DATASTREAM_AUTO_THRESHOLD conf?

public static final String OZONE_FS_DATASTREAM_AUTO_THRESHOLD
= "ozone.fs.datastream.auto.threshold";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure.

@guohao-rosicky guohao-rosicky requested a review from szetszwo June 26, 2023 12:37
Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 the change looks good.

@szetszwo szetszwo merged commit 2529f3d into apache:master Jun 28, 2023
errose28 added a commit to errose28/ozone that referenced this pull request Jun 30, 2023
* master:
  HDDS-8555. [Snapshot] When snapshot feature is disabled, block OM startup if there are still snapshots in the system (apache#4994)
  HDDS-8782. Improve Volume Scanner Health checks. (apache#4867)
  HDDS-8447. Datanodes should not process container deletes for failed volumes. (apache#4901)
  HDDS-5869. Added support for stream on S3Gateway write path (apache#4970)
  HDDS-8859. [Snapshot] Return failure message to client for a failed snapshot diff jobs (apache#4993)
  HDDS-8939. [Snapshot] isBlockLocationSame check should be skipped if object is not OmKeyInfo. (apache#4991)
  HDDS-8923. Expose XceiverClient cache stats as metrics (apache#4979)
  HDDS-8913. ContainerManagerImpl: reduce processing while locked (apache#4967)
  HDDS-8935. [Snapshot] Fallback to full diff if getDetlaFiles from compaction DAG fails (apache#4986)
  HDDS-8911. Update Hadoop to 3.3.6 (apache#4985)
  HDDS-8931. Allow EC PipelineChoosingPolicy to be defined separately from Ratis (apache#4983)
  HDDS-8895. Support dynamic change of ozone.readonly.administrators in SCM (apache#4977)
  HDDS-6814. Make OM service ID optional for `ozone s3` commands if only one is defined in config (apache#4953)
  HDDS-8925. BaseFreonGenerator may not complete if last attempts fail (apache#4975)
  HDDS-7100. Container scanner incorrectly marks containers unhealthy when DN is shutdown (apache#4951)
  HDDS-8919. Allow EC pipelines to be created and then added to PipelineManager in two steps (apache#4968)
  HDDS-8901. Enable mTLS for InterSCMGrpcProtocol. (apache#4964)

Conflicts:
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/interfaces/Container.java
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainer.java
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainerCheck.java
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/ContainerTestUtils.java
vtutrinov pushed a commit to Cyrill/ozone that referenced this pull request Jul 3, 2023
vtutrinov pushed a commit to Cyrill/ozone that referenced this pull request Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants